﻿/*
版权所有：版权所有(C) 2010，刘建新
文件编号：M01_Usermenu.cs
文件名称：Usermenu.cs
系统编号：Z0003007
系统名称：通用办公系统
模块编号：M01
模块名称：信息发布
设计文档：IOA_M01信息发布XDE建模.mdx
完成日期：2010/12/17
作　　者：
内容摘要：表[UserMenu]对应的实体类
*/

using System;
using System.Collections;
using System.Data;


namespace Eis51.CampanyCMS.Model.Bus
{
		/// <summary>
		/// 类 编 号：
		/// 类 名 称：Usermenu
		/// 内容摘要：
		/// </summary>
		
		[Serializable]
		public class Usermenu : BaseModel
		{
		#region 自动生成代码
		
			#region 重载Equals/GetHashCode
			/// <summary>
			/// 重载Equals			
			/// </summary>
			public override bool Equals (Object obj)
			{
				if (obj != null && obj is Usermenu)
				{
					if (obj == this)
						return true;
					Usermenu castObj = (Usermenu)obj; 
					
					if (!this.m_Seqno.Equals(castObj.Seqno))
						return false;
						
					if (!this.m_Id.Equals(castObj.Id))
						return false;
						
					if (!this.m_Title.Equals(castObj.Title))
						return false;
						
					if (!this.m_Navigateurl.Equals(castObj.Navigateurl))
						return false;
						
					if (!this.m_Admintype.Equals(castObj.Admintype))
						return false;
						
					if (!this.m_Show.Equals(castObj.Show))
						return false;
						
					if (!this.m_Imageurl.Equals(castObj.Imageurl))
						return false;
						
					if (!this.m_Createby.Equals(castObj.Createby))
						return false;
						
					if (!this.m_Createdate.Equals(castObj.Createdate))
						return false;
						
					if (!this.m_Parentid.Equals(castObj.Parentid))
						return false;
						
					if (!this.m_Isdefault.Equals(castObj.Isdefault))
						return false;
						
					return true;
				}
				return false;
			}
			
			/// <summary>
			/// 重载GetHashCode
			/// </summary>
			public override int GetHashCode()
			{
					int hash = 0;					
					
					hash = hash <<  8;
					if ((object)m_Seqno != null)
					{
						hash = hash ^ m_Seqno.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Id != null)
					{
						hash = hash ^ m_Id.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Title != null)
					{
						hash = hash ^ m_Title.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Navigateurl != null)
					{
						hash = hash ^ m_Navigateurl.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Admintype != null)
					{
						hash = hash ^ m_Admintype.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Show != null)
					{
						hash = hash ^ m_Show.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Imageurl != null)
					{
						hash = hash ^ m_Imageurl.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createby != null)
					{
						hash = hash ^ m_Createby.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Createdate != null)
					{
						hash = hash ^ m_Createdate.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Parentid != null)
					{
						hash = hash ^ m_Parentid.GetHashCode();
					}
						
					hash = hash <<  8;
					if ((object)m_Isdefault != null)
					{
						hash = hash ^ m_Isdefault.GetHashCode();
					}
						
					return hash; 
			}
			#endregion
			
			public Usermenu()
			{
				MarkNew();
			}						
			
			public Usermenu GetOldValue()
			{
				return OldValue as Usermenu;
			}
		
		#region Seqno属性
			private int m_Seqno = 0;
			/// <summary>
			/// 属性名称： Seqno
			/// 内容摘要： DB列名：Seqno[]
			///            DB类型：int
			/// </summary>
			public int Seqno
			{
				get
					{
						return m_Seqno;
					}
				set
					{
						if (m_Seqno as object == null || !m_Seqno.Equals(value))
						{
							m_Seqno = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Id属性
			private string m_Id = String.Empty;
			/// <summary>
			/// 属性名称： Id
			/// 内容摘要： DB列名：ID[]
			///            DB类型：string
			/// </summary>
			public string Id
			{
				get
					{
						return m_Id;
					}
				set
					{
						if (m_Id as object == null || !m_Id.Equals(value))
						{
							m_Id = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Title属性
			private string m_Title = String.Empty;
			/// <summary>
			/// 属性名称： Title
			/// 内容摘要： DB列名：Title[]
			///            DB类型：string
			/// </summary>
			public string Title
			{
				get
					{
						return m_Title;
					}
				set
					{
						if (m_Title as object == null || !m_Title.Equals(value))
						{
							m_Title = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Navigateurl属性
			private string m_Navigateurl = String.Empty;
			/// <summary>
			/// 属性名称： Navigateurl
			/// 内容摘要： DB列名：NavigateUrl[]
			///            DB类型：string
			/// </summary>
			public string Navigateurl
			{
				get
					{
						return m_Navigateurl;
					}
				set
					{
						if (m_Navigateurl as object == null || !m_Navigateurl.Equals(value))
						{
							m_Navigateurl = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Admintype属性
			private string m_Admintype = String.Empty;
			/// <summary>
			/// 属性名称： Admintype
			/// 内容摘要： DB列名：AdminType[]
			///            DB类型：string
			/// </summary>
			public string Admintype
			{
				get
					{
						return m_Admintype;
					}
				set
					{
						if (m_Admintype as object == null || !m_Admintype.Equals(value))
						{
							m_Admintype = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Show属性
			private int m_Show = 0;
			/// <summary>
			/// 属性名称： Show
			/// 内容摘要： DB列名：Show[]
			///            DB类型：int
			/// </summary>
			public int Show
			{
				get
					{
						return m_Show;
					}
				set
					{
						if (m_Show as object == null || !m_Show.Equals(value))
						{
							m_Show = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Imageurl属性
			private string m_Imageurl = String.Empty;
			/// <summary>
			/// 属性名称： Imageurl
			/// 内容摘要： DB列名：ImageUrl[]
			///            DB类型：string
			/// </summary>
			public string Imageurl
			{
				get
					{
						return m_Imageurl;
					}
				set
					{
						if (m_Imageurl as object == null || !m_Imageurl.Equals(value))
						{
							m_Imageurl = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createby属性
			private string m_Createby = String.Empty;
			/// <summary>
			/// 属性名称： Createby
			/// 内容摘要： DB列名：CreateBy[]
			///            DB类型：string
			/// </summary>
			public string Createby
			{
				get
					{
						return m_Createby;
					}
				set
					{
						if (m_Createby as object == null || !m_Createby.Equals(value))
						{
							m_Createby = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Createdate属性
			private DateTime m_Createdate = new DateTime(1900,1,1);
			/// <summary>
			/// 属性名称： Createdate
			/// 内容摘要： DB列名：CreateDate[]
			///            DB类型：DateTime
			/// </summary>
			public DateTime Createdate
			{
				get
					{
						return DateTime.Parse(m_Createdate.ToString("yyyy-MM-dd HH:mm:ss"));
					}
				set
					{
						if (m_Createdate as object == null || !m_Createdate.Equals(value))
						{
							m_Createdate = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Parentid属性
			private int m_Parentid = 0;
			/// <summary>
			/// 属性名称： Parentid
			/// 内容摘要： DB列名：ParentId[]
			///            DB类型：int
			/// </summary>
			public int Parentid
			{
				get
					{
						return m_Parentid;
					}
				set
					{
						if (m_Parentid as object == null || !m_Parentid.Equals(value))
						{
							m_Parentid = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region Isdefault属性
			private int m_Isdefault = 0;
			/// <summary>
			/// 属性名称： Isdefault
			/// 内容摘要： DB列名：IsDefault[]
			///            DB类型：int
			/// </summary>
			public int Isdefault
			{
				get
					{
						return m_Isdefault;
					}
				set
					{
						if (m_Isdefault as object == null || !m_Isdefault.Equals(value))
						{
							m_Isdefault = value;
							MarkUpdated();
						}						
					}
			}
		#endregion
		
		#region static CreateDataTable/FillDataRow/DataRow2Obj/Dt2Objs/FillDataTable
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="tableName">表名</param>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(string tableName,ColumnNameEnum cne)
			{
				DataTable dtResult = new DataTable(tableName);
			
				if (cne == ColumnNameEnum.DBName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("ID",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Title",typeof(string)));
					dtResult.Columns.Add(new DataColumn("NavigateUrl",typeof(string)));
					dtResult.Columns.Add(new DataColumn("AdminType",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Show",typeof(int)));
					dtResult.Columns.Add(new DataColumn("ImageUrl",typeof(string)));
					dtResult.Columns.Add(new DataColumn("CreateBy",typeof(string)));
					dtResult.Columns.Add(new DataColumn("CreateDate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("ParentId",typeof(int)));
					dtResult.Columns.Add(new DataColumn("IsDefault",typeof(int)));
				}
				else if (cne == ColumnNameEnum.PropertyName)
				{
					dtResult.Columns.Add(new DataColumn("Seqno",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Id",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Title",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Navigateurl",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Admintype",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Show",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Imageurl",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Createby",typeof(string)));
					dtResult.Columns.Add(new DataColumn("Createdate",typeof(DateTime)));
					dtResult.Columns.Add(new DataColumn("Parentid",typeof(int)));
					dtResult.Columns.Add(new DataColumn("Isdefault",typeof(int)));
				}
				return dtResult;
			}
			
			/// <summary>
			/// 得到实体对应的DataTable
			/// </summary>
			/// <param name="cne">列名映射选择:DB列名或属性名</param>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable(ColumnNameEnum cne)
			{
				return CreateDataTable(null,cne);
			}

			/// <summary>
			/// 得到实体对应的DataTable(默认列名映射为属性名)
			/// </summary>
			/// <returns>生成的DataTable</returns>
			static public DataTable CreateDataTable()
			{
				return CreateDataTable(ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			public void FillDataRow(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				if (ColumnNameEnum.DBName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["ID"] = this.Id;
					dr["Title"] = this.Title;
					dr["NavigateUrl"] = this.Navigateurl;
					dr["AdminType"] = this.Admintype;
					dr["Show"] = this.Show;
					dr["ImageUrl"] = this.Imageurl;
					dr["CreateBy"] = this.Createby;
					dr["CreateDate"] = this.Createdate;
					dr["ParentId"] = this.Parentid;
					dr["IsDefault"] = this.Isdefault;
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					dr["Seqno"] = this.Seqno;
					dr["Id"] = this.Id;
					dr["Title"] = this.Title;
					dr["Navigateurl"] = this.Navigateurl;
					dr["Admintype"] = this.Admintype;
					dr["Show"] = this.Show;
					dr["Imageurl"] = this.Imageurl;
					dr["Createby"] = this.Createby;
					dr["Createdate"] = this.Createdate;
					dr["Parentid"] = this.Parentid;
					dr["Isdefault"] = this.Isdefault;					
				}
			}
			
			/// <summary>
			/// 用当前对象值填充DaraRow(默认列名映射为属性名)
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			public void FillDataRow(DataRow dr)
			{
				this.FillDataRow(dr,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 将DataRow转换成Usermenu对象
			/// </summary>
			/// <param name="dr">由CreateTable生成的DataTable通过NewRow得到的DataRow对象</param>
			/// <param name="cne">dr的列名映射方式:DB列名或属性名</param>
			/// <returns>Usermenu对象</returns>
			public static Usermenu Dr2Obj(DataRow dr,ColumnNameEnum cne)
			{
				if (dr == null)
				{
					throw new ArgumentNullException("dr");
				}
				Usermenu obj = new Usermenu();
				if (ColumnNameEnum.DBName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.Id = (dr["ID"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["ID"],typeof(string));
					obj.Title = (dr["Title"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Title"],typeof(string));
					obj.Navigateurl = (dr["NavigateUrl"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["NavigateUrl"],typeof(string));
					obj.Admintype = (dr["AdminType"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["AdminType"],typeof(string));
					obj.Show = (dr["Show"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Show"],typeof(int));
					obj.Imageurl = (dr["ImageUrl"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["ImageUrl"],typeof(string));
					obj.Createby = (dr["CreateBy"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["CreateBy"],typeof(string));
					obj.Createdate = (dr["CreateDate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["CreateDate"],typeof(DateTime));
					obj.Parentid = (dr["ParentId"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["ParentId"],typeof(int));
					obj.Isdefault = (dr["IsDefault"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["IsDefault"],typeof(int));
				}
				else if (ColumnNameEnum.PropertyName == cne)
				{
					obj.Seqno = (dr["Seqno"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Seqno"],typeof(int));
					obj.Id = (dr["Id"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Id"],typeof(string));
					obj.Title = (dr["Title"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Title"],typeof(string));
					obj.Navigateurl = (dr["Navigateurl"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Navigateurl"],typeof(string));
					obj.Admintype = (dr["Admintype"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Admintype"],typeof(string));
					obj.Show = (dr["Show"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Show"],typeof(int));
					obj.Imageurl = (dr["Imageurl"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Imageurl"],typeof(string));
					obj.Createby = (dr["Createby"] == Convert.DBNull) ? null  : (string)Convert.ChangeType(dr["Createby"],typeof(string));
					obj.Createdate = (dr["Createdate"] == Convert.DBNull) ? new DateTime(1900,1,1)  : (DateTime)Convert.ChangeType(dr["Createdate"],typeof(DateTime));
					obj.Parentid = (dr["Parentid"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Parentid"],typeof(int));
					obj.Isdefault = (dr["Isdefault"] == Convert.DBNull) ? 0  : (int)Convert.ChangeType(dr["Isdefault"],typeof(int));		
				}
				
				return obj;
			}
			
			/// <summary>
			/// 将DataRow转换成Usermenu对象(默认列名映射为属性名)
			/// </summary>
			/// <returns>Usermenu对象</returns>
			public static Usermenu Dr2Obj(DataRow dr)
			{
				return Dr2Obj(dr,ColumnNameEnum.DBName);
			}
			
			/// <summary>
			/// 将DataTabe转换成的Usermenu对象集合
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			/// <returns>Usermenu对象的集合</returns>
			public static IList Dt2Objs(DataTable dt,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				
				ArrayList alResult = new ArrayList();
				
				foreach(DataRow dr in dt.Rows)
				{
					alResult.Add(Dr2Obj(dr,cne));
				}
				
				return alResult;
			}

			/// <summary>
			/// 将DataTabe转换成的Usermenu对象集合(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <returns>Usermenu对象的集合</returns>
			public static IList Dt2Objs(DataTable dt)
			{
				return Dt2Objs(dt,ColumnNameEnum.PropertyName);
			}
			
			/// <summary>
			/// 用objs的Usermenu对象集合填充DataTable
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Usermenu对象集合</param>
			/// <param name="cne">dt的列名映射方式:DB列名或属性名</param>
			public static void FillDataTable(DataTable dt,IList objs,ColumnNameEnum cne)
			{
				if (dt == null)
				{
					throw new ArgumentNullException("dt");
				}
				if (objs == null)
				{
					throw new ArgumentNullException("objs");
				}
				
				foreach(Usermenu obj in objs)
				{
					DataRow dr = dt.NewRow();
					obj.FillDataRow(dr,cne);
					dt.Rows.Add(dr);
				}
			}

			/// <summary>
			/// 用objs的Usermenu对象集合填充DataTable(默认列名映射为属性名)
			/// </summary>
			/// <param name="dt">由CreateTable生成的DataTable</param>
			/// <param name="objs">Usermenu对象集合</param>
			public static void FillDataTable(DataTable dt,IList objs)
			{
				FillDataTable(dt,objs,ColumnNameEnum.PropertyName);
			}
		#endregion
		
		/// <summary>
		/// 取消编辑,恢复到上次有效调用BeginEdit前的状态,并清空保留值
		/// </summary>
		public override void CancelEdit()
		{
			Usermenu old = this.OldValue as Usermenu;
			if (old != null)
			{
					this.Seqno = old.Seqno;
					this.Id = old.Id;
					this.Title = old.Title;
					this.Navigateurl = old.Navigateurl;
					this.Admintype = old.Admintype;
					this.Show = old.Show;
					this.Imageurl = old.Imageurl;
					this.Createby = old.Createby;
					this.Createdate = old.Createdate;
					this.Parentid = old.Parentid;
					this.Isdefault = old.Isdefault;				
				this.OldValue = null;
			}
		}
		
		
		
		
		#region Usermenu实体的内部Key类
			/// <summary>
			/// Usermenu实体的Key类
			/// </summary>
			public sealed class Key
			{
		
				private int m_Seqno;
				public int Seqno
				{
 					get 
					{ 
						 return m_Seqno; 
					}
					set 
					{ 
						m_Seqno = value;
					}
				}
		
				public Key(int pSeqno)
				{
					m_Seqno=pSeqno;

				}
			}
		#endregion
			/// <summary>
			/// 得到实体Usermenu的PK
			/// </summary>
			public Key GetKey()
			{
				return new Key(Seqno);				
			}
			
				
		#endregion
	}
}
